<?php


namespace App\Listeners\RechargeSuccessEvent;

use App\Events\RechargeSuccessEvent;
use App\Services\Member\Interfaces\UserServiceInterface;
use App\Services\Member\Services\UserService;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;


class TransferBalanceListener implements ShouldQueue
{

    /**
     * @var UserService
     */
    protected $userService;

    public function __construct(
        UserServiceInterface $userService
    )
    {
        $this->userService = $userService;
    }

    /**
     * Handle the event.
     *
     * @param RechargeSuccessEvent $event
     * @return void
     */
    public function handle(RechargeSuccessEvent $event)
    {


        $order = $event->order;
        $this->userService->tansferIn($order['user_id'], $order['charge']);
    }
}
